package com.example.initproj.base.param

import org.aspectj.lang.JoinPoint
import org.aspectj.lang.annotation.Aspect
import org.aspectj.lang.annotation.Before
import org.aspectj.lang.annotation.Pointcut
import org.springframework.stereotype.Component

/**
 *
 * Author: Gao Xiang
 * Create: 2020/12/30
 * Description: 参数检查 切面，不通过直接返回错误
 *
 **/

@Aspect
@Component
class RequestAspect {

    companion object{
        private const val TAG = "RequestAspect"
    }

    @Pointcut("execution(public * *(ARequest+,..))")
    fun point(){}

    @Before("point()")
    fun checkRequest(join: JoinPoint){
        join.args.forEach {
            if(it is ARequest){
                it.validate()
            }
        }
    }

}